<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="counter">
        <button @click="reduce">-</button>
        {{counterNum}}
        <button @click="add">+</button>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const counterApp = new Vue({
            el:'#counter',
            data(){
                return{
                    counterNum:0
                }
            },
            methods:{
                reduce(){
                    if(this.counterNum > 0){
                        this.counterNum--
                    }else{
                        console.log('最小为0')
                    }
                },
                add(){
                    if(this.counterNum < 10){
                        this.counterNum++
                    }else{
                        console.log('最大为10')
                    }
                }
            }
        })
    </script>
</body>
</html>